package org.yzl.designPatterns.flyweight;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class IgoChessmanFactory {
    private static Hashtable hb = new Hashtable();
    private static IgoChessmanFactory instance = new IgoChessmanFactory();
    private IgoChessmanFactory(){
        IgoChessman white,black = null;
        white = new WhiteIgoChessman();
        hb.put("w", white);
        black = new BlackIgoChessman();
        hb.put("b", black);
    };

    //返回享元工厂类的唯一实例
    public static IgoChessmanFactory getInstance() {
        return instance;
    }

    //通过key来获取存储在Hashtable中的享元对象
    public IgoChessman getIgoChessman(String color) {
        return (IgoChessman)hb.get(color);
    }

}
